package org.iss.ip.service;

import javax.transaction.Transactional;

import org.iss.ip.bean.User;
import org.iss.ip.dao.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

	@Autowired
	private UserRepository userRepository;
	
	/**
	 * 根据用户名进行查找
	 * @param username
	 * @return
	 */
	@Transactional
	public User findByUsername(String username){
		return userRepository.findByUsername(username);
	}
	/**
	 * 保存用户（更新）
	 * @param user
	 */
	@Transactional
	public void save(User user){
		userRepository.save(user);
	}
	/**
	 * 判断用户是否存在
	 * @param id
	 * @return
	 */
	@Transactional
	public boolean exist(int id){
		return userRepository.exists(id);
	}
}
